<template>
  <!-- 订单支付 -->
  <el-dialog
    title="订单支付"
    :visible.sync="dialogTableVisible"
    :close-on-click-modal="modalDialog"
    :close-on-press-escape="modalDialog"
    top="15vh !important"
    :before-close="cancelOrder"
    width="1000px"
    append-to-body
  >
    <div class="orderBox">
      <div class="orderLeft">
        <div class="orderPriceBt">订单金额：{{ orderMessgae.allPrice }}</div>
        <div v-if="type != 'bracelet'" class="gjCnt">
          消费金额：
          <!-- <el-input
            v-if="modPrice"
            v-model="modPValue"
            maxlength="10"
            clearable
            oninput="value=value.replace(/[^0-9]{0,1}(\d*(?:\.\d{0,2})?).*$/g, '$1');"
            placeholder="请输入新价格"
          /> -->
          <el-input-number
            v-if="modPrice"
            v-model="modPValue"
            style="width: 140px"
            maxlength="10"
            clearable
            placeholder="请输入新价格"
            :precision="2"
            :step="0.1"
            :min="0"
            @change="gjChange"
          />
          <el-input v-if="!modPrice" v-model="orderMessgae.allPrice" disabled />
          元
          <el-checkbox
            v-if="payType != 10 && canMod && type != 'defaultReserve'&& type != 'vipRecharge' && type != 'vipAdd' && type != 'lease' && type != 'leaseList'"
            v-model="modPrice"
            style="margin-left: 10px;"
          >订单改价</el-checkbox>
        </div>
        <template
          v-if="type == 'specialCardBuy'"
        >
          <el-table
            :data="orderMessgae.specialCardOrderInfo"
            border
            fit
            max-height="230"
            :header-row-class-name="'table-header'"
            class="doumee-element-table"
          >
            <el-table-column
              align="center"
              label="商品"
              prop="name"
              min-width="120"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="单价"
              prop="partPrice"
              min-width="70"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="数量"
              prop="num"
              min-width="60"
              show-overflow-tooltip
            />
          </el-table>
        </template>
        <template
          v-if="(type == 'goodsSale' ||
            type == 'goods' ||
            type == 'table' ||
            type == 'financeDefaultSpend' ||
            type == 'handlingFees' ||
            type == 'dinner') && orderMessgae.goodsInfos && orderMessgae.goodsInfos.length > 0"
        >
          <el-table
            :data="orderMessgae.goodsInfos"
            border
            fit
            max-height="230"
            :header-row-class-name="'table-header'"
            class="doumee-element-table"
          >
            <el-table-column label="订单信息" show-overflow-tooltip>
              >
              <template slot-scope="scope">
                {{ type == 'handlingFees'?scope.row.name :scope.row }}{{ type == 'handlingFees'?scope.row.partPrice + '元' : '' }}
              </template></el-table-column>
          </el-table>
        </template>
        <template
          v-if="
            type == 'assemblyField' &&
              orderMessgae.detail &&
              orderMessgae.detail.length > 0
          "
        >
          <el-table
            :data="orderMessgae.detail"
            border
            fit
            max-height="230"
            :header-row-class-name="'table-header'"
            class="doumee-element-table"
          >
            <el-table-column
              align="center"
              label="约球/拼场名称"
              prop="name"
              min-width="120"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="活动项目"
              prop="projectName"
              min-width="100"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="报名费(元)"
              prop="price"
              min-width="100"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="活动时间"
              min-width="190"
              prop="acTime"
              show-overflow-tooltip
            />
          </el-table>
        </template>
        <template
          v-if="(type == 'goodsSale' ||
            type == 'goods' ||
            type == 'table' ||
            type == 'financeDefaultSpend' ||
            type == 'dinner') && (!orderMessgae.goodsInfos || orderMessgae.goodsInfos.length == 0)
          "
        >
          <el-table :data="[orderMessgae.goodsInfo]" max-height="230" border fit :header-row-class-name="'table-header'" class="doumee-element-table">
            <el-table-column label="订单信息" show-overflow-tooltip>
              >
              <template slot-scope="scope">
                {{ scope.row }}
              </template></el-table-column>
          </el-table>
        </template>
        <template v-if="type == 'areaSellOrder' || type == 'defaultReserve'">
          <el-table
            :data="orderMessgae.siteList"
            max-height="230"
            border
            fit
            :header-row-class-name="'table-header'"
            class="doumee-element-table"
          >
            <el-table-column label="场地名称" show-overflow-tooltip prop="siteModelName" align="center" />
            <el-table-column label="时间" show-overflow-tooltip align="center">
              <template slot-scope="scope">
                {{ scope.row.beginTime + " - " + scope.row.endTime }}
              </template></el-table-column>
            <el-table-column label="费用" show-overflow-tooltip prop="price" width="80" align="center">
              <template slot-scope="scope">
                {{ scope.row.price || 0 }} 元
              </template></el-table-column>
          </el-table>
        </template>
        <template v-if="type == 'escort'">
          <el-table
            :data="[orderMessgae]"
            max-height="230"
            border
            fit
            :header-row-class-name="'table-header'"
            class="doumee-element-table"
          >
            <el-table-column label="商品" show-overflow-tooltip prop="escortName" align="center" />
            <el-table-column label="单价" show-overflow-tooltip align="center" prop="price" />
            <el-table-column label="数量" show-overflow-tooltip width="80" align="center">
              <template slot-scope="scope">1</template>
            </el-table-column>
          </el-table>
        </template>
        <template v-if="type == 'bracelet'">
          <el-table
            :data="orderMessgae.goodsInfo"
            max-height="230"
            border
            fit
            :header-row-class-name="'table-header'"
            class="doumee-element-table"
          >
            <el-table-column label="手环" show-overflow-tooltip prop="braceletId" align="center" />
            <el-table-column label="押金" show-overflow-tooltip align="center" prop="price" width="80" />
            <el-table-column label="数量" show-overflow-tooltip prop="num" width="80" align="center" />
          </el-table>
        </template>
        <template v-if="type == 'comboOrder' || type == 'combo'">
          <el-table
            :data="orderMessgae.mealsPaysResponseParamList"
            max-height="230"
            border
            fit
            :header-row-class-name="'table-header'"
            class="doumee-element-table"
          >
            <el-table-column v-if="orderMessgae.mealsPaysResponseParamList[0].mealsType != '3' && orderMessgae.mealsPaysResponseParamList[0].mealsType != '4'" label="项目名称" show-overflow-tooltip prop="projectNmae" align="center">
              <template slot-scope="scope">
                <span v-if="scope.row.mealsType != '3' && scope.row.mealsType != '4'">{{ scope.row.projectNmae }}</span>
              </template>
            </el-table-column>
            <el-table-column label="套餐" show-overflow-tooltip prop="name" align="center" />
            <el-table-column label="价格" show-overflow-tooltip prop="price" align="center" width="80">
              <template slot-scope="scope">
                {{ scope.row.price || 0 }}元
              </template></el-table-column>
            <el-table-column label="数量" show-overflow-tooltip prop="mealsNum" align="center" width="80" />
          </el-table>
        </template>
        <template v-if="type == 'lease' || type == 'leaseList'">
          <el-table
            :data="orderMessgae.equipmentConfirmRespParamList"
            max-height="230"
            border
            fit
            :header-row-class-name="'table-header'"
            class="doumee-element-table"
          >
            <el-table-column label="器材名称" show-overflow-tooltip prop="name" align="center" min-width="90" />
            <el-table-column label="押金" show-overflow-tooltip prop="deposit" align="center" min-width="70" />
            <el-table-column label="收费标准" show-overflow-tooltip prop="chargeInfo" align="center" min-width="120" />
            <el-table-column label="免费时长(分钟)" show-overflow-tooltip prop="freeTime" align="center" min-width="110">
              <template slot-scope="scope">
                {{ scope.row.freeTime || 0 }}
              </template></el-table-column>
          </el-table>
        </template>
        <template v-if="type == 'ticket' || type == 'ticketOrder'">
          <el-table
            :data="orderMessgae.ticketPaysResponseParamList"
            max-height="230"
            border
            fit
            :header-row-class-name="'table-header'"
            class="doumee-element-table"
          >
            <el-table-column label="项目名称" show-overflow-tooltip prop="projectNmae" align="center" />
            <el-table-column label="门票" show-overflow-tooltip prop="name" align="center" />
            <el-table-column label="价格" show-overflow-tooltip prop="price" align="center" width="80">
              <template slot-scope="scope">
                {{ scope.row.price || 0 }}元
              </template></el-table-column>
            <el-table-column label="数量" show-overflow-tooltip prop="num" align="center" width="80" />
            <el-table-column label="押金" show-overflow-tooltip prop="price" align="center" width="80">
              <template slot-scope="scope">
                {{ scope.row.deposit || 0 }}
              </template></el-table-column>
          </el-table>
        </template>
        <template
          v-if="type == 'vipRecharge'"
        >
          <el-table :data="[orderMessgae]" max-height="230" border fit :header-row-class-name="'table-header'" class="doumee-element-table">
            <el-table-column label="会员信息" show-overflow-tooltip prop="nickName" align="center" />
            <el-table-column label="会员等级" show-overflow-tooltip prop="cardName" align="center" />
            <el-table-column label="充值金额" show-overflow-tooltip align="center" width="80">
              <template slot-scope="scope">
                {{ scope.row.originalPrice || orderMessgae.allPrice }}元
              </template></el-table-column>
            <el-table-column label="赠送金额" show-overflow-tooltip align="center" width="80">
              <template slot-scope="scope">
                {{ scope.row.giveMoney || 0 }}元
              </template></el-table-column>
          </el-table>
        </template>
        <template
          v-if="type == 'studentAdd'"
        >
          <el-table :data="[orderMessgae]" max-height="230" border fit :header-row-class-name="'table-header'" class="doumee-element-table">
            <el-table-column label="课程信息" show-overflow-tooltip prop="courseName" align="center" width="100" />
            <el-table-column label="授课教练" show-overflow-tooltip prop="teacherName" align="center" width="80" />
            <el-table-column v-if="orderMessgae.beginDate" label="课程时间" show-overflow-tooltip align="center" width="120" prop="beginDate" />
            <el-table-column label="课程价格" show-overflow-tooltip align="center" width="80" prop="allPrice" />
            <el-table-column label="课程类型" show-overflow-tooltip align="center" width="80">
              <template slot-scope="scope">
                {{ scope.row.courseType ==1?'团体课':scope.row.courseType ==2 || scope.row.courseType ==4?'私教课':'常规课' }}
              </template></el-table-column>
            <el-table-column label="学员姓名" show-overflow-tooltip align="center" width="80" prop="student" />
          </el-table>
        </template>
        <template
          v-if="type == 'vipAdd'"
        >
          <el-table :data="[orderMessgae]" max-height="230" border fit :header-row-class-name="'table-header'" class="doumee-element-table">
            <el-table-column label="会员卡购买" show-overflow-tooltip prop="cardName" align="center" />
            <el-table-column label="卡号" show-overflow-tooltip prop="number" align="center" />
          </el-table>
        </template>
        <template
          v-if="type == 'groupOpen'"
        >
          <el-table :data="[orderMessgae]" max-height="230" border fit :header-row-class-name="'table-header'" class="doumee-element-table">
            <el-table-column label="订单信息" show-overflow-tooltip prop="orderInfo" />
          </el-table>
        </template>
      </div>
      <div class="orderRight">
        <el-form ref="form" @submit.native.prevent>
          <el-input
            v-if="(hyxz && payType === '01') || (hyxz && (payType === '10' || payType === '04' || payType === '02' || payType === '05' || payType === '08' || payType === '07') && fyms === '0')"
            v-model="cardNum"
            placeholder="请输卡号/手机号"
            style="width: 100%;margin-bottom: 10px"
            clearable
            @keyup.enter.native="searchAction"
          >
            <el-button slot="append" icon="el-icon-search" @click="searchAction" />
          </el-input>
          <div v-if="showMessage && cardMessage.nickName" class="memberDetail">
            <img src="@/icons/png/default_pic.png" width="40px" height="40px">
            <div class="memberRight">
              <div>
                {{ cardMessage.nickName }}
              </div>
              <div>账户余额：<span class="money">{{ cardMessage.remainingMoney || 0 }} / {{ cardMessage.remainingGiveMoney || 0
              }}</span></div>
              <div>
                会员等级：<span>{{ cardMessage.cardName }}</span>
              </div>
            </div>
          </div>
          <div class="zffsBt">支付方式：</div>
          <template v-for="(item, index) in payTypes">
            <el-button
              v-if="!((orderMessgae.userType == 1 &&item.value == '01' && (type == 'areaSellOrder' || type == 'assemblyField')) || !item.show)"
              :key="index"
              v-preventReClick
              class="pay-style"
              :class="payTypes[index].value == payType
                ? 'slelect-pay-style'
                : 'normal-pay-style'
              "
              type="text"
              @click="changePayType(item)"
            >{{ item.name }}</el-button>
          </template>
          <div v-if="payType === '14'" class="zffsBt mt10" style="display: flex;align-items: center;justify-content: space-between;">
            会员卡支付：<span class="red" style="font-size: 14px;font-weight: bolder;">{{ cardPayPrice }}</span>
          </div>
          <div v-if="payType === '14'" class="zffsBt mt10" style="display: flex;align-items: center;justify-content: space-between;">
            剩余需支付：
            <span class="red" style="font-size: 14px;font-weight: bolder;">{{ modPrice && modPValue > 0
              ? (Number(modPValue) - Number(cardPayPrice)).toFixed(2)
              : (Number(lastPrice.price) - Number(cardPayPrice)).toFixed(2) }}</span>
          </div>
          <div v-if="payType === '14'" class="zffsBt mt10" style="display: flex;align-items: center;justify-content: space-between;">
            <el-select v-model="payTypeb" placeholder="请选择混合付方式" style="width: 220px;margin-right: 10px;" @change="changePayTypeb">
              <el-option
                v-for="(item, index) in payTypebs"
                :key="index"
                :label="item.name"
                :value="item.value"
              >{{ item.name }}</el-option>
            </el-select>
            <el-input v-if="payTypeb === '10'" v-model="mtTgh" clearable maxlength="50" placeholder="请输入美团团购号" style="flex: 1;" />
            <el-input v-if="payTypeb === '04'" v-model="authCode" v-focus placeholder="请使用扫码枪扫描支付宝付款码" clearable style="flex: 1;" />
            <el-input v-if="payTypeb === '05'" v-model="authCode" v-focus placeholder="请使用扫码枪扫描微信付款码" clearable style="flex: 1;" />
            <el-input v-if="payTypeb === '08'" v-model="authCode" v-focus placeholder="请使用扫码枪扫描付款码" clearable style="flex: 1;" />
            <div v-if="payTypeb === '02'" class="sjfk" style="flex: 1;display: flex;align-items: center;justify-content: space-between;">
              <el-input-number
                v-model="payMoney"
                style="width: 140px;margin: 0 4px"
                maxlength="10"
                size="large"
                clearable
                placeholder="请输入实付金额"
                :precision="2"
                :step="0.1"
                :min="0"
                @input="payByMoneyb"
              />
              <span style="font-size: 14px;">找零：<b class="red">{{ changeMoney.toFixed(2) }}</b></span>
            </div>
          </div>

          <el-select
            v-if="payType === '13'"
            v-model="msCardId"
            placeholder="请选择专项卡"
            style="width: 100%"
            class="mb20"
            clearable
            @change="getOrderPrice"
          >
            <el-option
              v-for="item in specialList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
          <el-select
            v-if="payType === '01' && mealsList.length > 0"
            v-model="mealsMemberId"
            placeholder="请选择预定次卡"
            style="width: 100%"
            clearable
            @change="getOrderPrice"
          >
            <el-option
              v-for="item in mealsList"
              :key="item.id"
              :label="item.label"
              :value="item.id"
            />
          </el-select>
          <div style="display: flex;align-items: center;height: 40px;margin-bottom: 10px;">
            <span>预付定金：</span>
            <el-select
              v-model="yfdjId"
              placeholder="请选择预付定金"
              style="width: 150px"
              clearable
              @change="getOrderPrice(1)"
            >
              <el-option
                v-for="item in yfdjList"
                :key="item.id"
                :label="'￥'+item.allPrice"
                :value="item.id"
              />
            </el-select>
            <el-button type="primary" class="ml10" @click="replacementBtn">会员更改</el-button>
          </div>
          <el-form-item v-if="payType === '10'" label="美团团购号" label-width="6em">
            <el-input v-model="mtTgh" clearable maxlength="50" placeholder="请输入美团团购号" />
          </el-form-item>
          <el-form-item v-else-if="payType === '04'" label="付款码" label-width="4em">
            <el-input v-model="authCode" v-focus placeholder="请使用扫码枪扫描支付宝付款码" clearable />
          </el-form-item>
          <el-form-item v-else-if="payType === '05'" label="付款码" label-width="4em">
            <el-input v-model="authCode" v-focus placeholder="请使用扫码枪扫描微信付款码" clearable />
          </el-form-item>
          <el-form-item v-else-if="payType === '08'" label="付款码" label-width="4em">
            <el-input v-model="authCode" v-focus placeholder="请使用扫码枪扫描付款码" clearable />
          </el-form-item>
          <div v-if="lastPrice.policyId && lastPrice.policyName && payType !== '14'" class="yhzc">
            优惠政策：<span>{{ lastPrice.policyName }}</span>
          </div>
          <el-form-item
            v-if="payType === '01' && lastPrice.useIntegral && payType !== '14' &&
              lastPrice.useAmot &&
              !changePrice"
            label="积分抵扣"
            label-width="5em"
            style="margin-bottom: 10px;"
          >
            <el-switch
              v-model="integralUse"
              :active-value="'1'"
              :inactive-value="'0'"
              :active-text="'使用' + lastPrice.useIntegral + '积分抵扣' + lastPrice.useAmot + '元'"
            />
          </el-form-item>
          <el-form-item
            v-if="payType === '13' && lastPrice.useIntegral && payType !== '14' &&
              lastPrice.useAmot &&
              !changePrice"
            label="积分抵扣"
            label-width="5em"
            style="margin-bottom: 10px;"
          >
            <el-switch
              v-model="integralUse"
              :active-value="'1'"
              :inactive-value="'0'"
              :active-text="'使用' + lastPrice.useIntegral + '积分抵扣' + lastPrice.useAmot + '元'"
            />
          </el-form-item>
          <el-form-item v-if="payType === '01' || (payType === '14' && payTypeb === '01')" label="赠送金额" label-width="5em">
            <el-switch v-model="giveMoney" :active-value="true" :inactive-value="false" active-text="优先扣除赠送金额" />
          </el-form-item>
          <el-form-item v-if="payType === '03' || (payType === '14' && payTypeb === '03')" label="扣款顺序" label-width="5em">
            <el-switch v-model="giveMoney" :active-value="true" :inactive-value="false" active-text="优先扣除赠送金额" />
          </el-form-item>
          <el-form-item>
            <el-input v-model="remark" placeholder="请输入订单备注信息" clearable />
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div class="footCnt">
      <div v-if="hasLastPrice" class="bottom-left">
        应付金额：
        <span class="ysje">¥{{
          modPrice
            ? modPValue || 0
            : integralUse == "0"
              ? lastPrice.price
              : (Number(lastPrice.price) - Number(lastPrice.useAmot)).toFixed(2)
        }}</span>
        <template v-if="!modPrice && ((integralUse == '0' && (lastPrice.originalPrice - lastPrice.price)>0) || (integralUse == '1' && (lastPrice.originalPrice - (lastPrice.price - lastPrice.useAmot))>0))">
          优惠金额：
          <span class="discoun-style">{{
            modPrice
              ? 0
              : integralUse == "1"
                ? (
                  lastPrice.originalPrice -
                  (lastPrice.price - lastPrice.useAmot)
                ).toFixed(2)
                : (lastPrice.originalPrice - lastPrice.price).toFixed(2)
          }}</span>
          <span class="dis-title-style">元</span>
        </template>
      </div>
      <div class="bottom-right">
        <div v-if="payType === '02'" class="sjfk">
          实付现金：
          <el-input-number
            v-model="payMoney"
            style="width: 140px;margin: 0 4px"
            maxlength="10"
            clearable
            placeholder="请输入金额"
            :precision="2"
            :step="0.1"
            :min="0"
            @input="payByMoney"
          />
          找零：
          <b>{{ changeMoney.toFixed(2) }}</b>
        </div>
        <div v-if="(payType === '01' && lastPrice.isRequired === '1') || (payType === '14' && lastPrice.isRequired === '1')" class="sjfk">
          支付密码：
          <el-input
            v-model="cardPwd"
            type="password"
            style="width: 150px;"
            placeholder="请输入支付密码"
            maxlength="6"
            clearable
            oninput="value=value.replace(/[^\d]/g,'')"
          />
        </div>
        <el-button type="primary" :loading="payLoading" style="margin-left: 20px" @click="payOrder">结账</el-button>
      </div>
    </div>
    <el-dialog
      title="扫码支付"
      :visible.sync="showSm"
      :close-on-click-modal="modalDialog"
      :close-on-press-escape="modalDialog"
      :append-to-body="true"
      top="20vh !important"
      width="500px"
    >
      <div class="smtip">请扫描客户付款码</div>
      <img src="@/icons/png/ic_saomiao.png" width="200px" height="200px" class="smImg">
      <div class="smFoot">
        <el-input ref="code" v-model="smCode" v-focus placeholder="请扫客户付款码" clearable @keyup.enter.native="smQrbtn" />
        <el-button type="primary" style="margin-left: 20px" @click="smQrbtn">确认</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="会员更改"
      :visible.sync="showReplacement"
      :close-on-click-modal="modalDialog"
      :close-on-press-escape="modalDialog"
      :append-to-body="true"
      top="20vh !important"
      width="500px"
    >
      <div v-if="replacement.id" style="height: 40px;display: flex;align-items: center;">当前会员：{{ replacement.nickName }} {{ replacement.jobNo? '+' + replacement.jobNo: '' }}</div>
      <div v-else style="height: 40px;display: flex;align-items: center;">当前会员：{{ cardMessage.nickName }} {{ cardMessage.jobNo? '+' + cardMessage.jobNo: '' }}</div>
      <div v-if="showReplacement" style="width: 100%;">
        <MemberSearch
          ref="memberSearchRef"
          @clear="tgMemberClear"
          @select="tgMemberSelect"
        />
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closewReplacement">取消</el-button>
        <el-button
          v-preventReClick
          type="primary"
          @click="confirmReplacement"
        >确定</el-button>
      </div>
    </el-dialog>
  </el-dialog>
</template>

<script>
import { printOrder, courseGoOnPay, escortPayInfo, ableOrienteerByOrder, equipmentLeaseContinuePay, configList, equipmentLeaseConfirm, getOneByOrderAndMember, getPrice, scanCodePay, orderType, payForOrder, VIPInfo, goodsOrderContinuePay, goodsPayForVenue, memberInfo, mealPayInfo, ticketPayAgain, payInfo, siteOrderInfo, mealsReserveCard, enrolCoursePc } from '@/api'
import { mealInfo } from '@/api/combo'
import MemberSearch from '@/components/MemberSearch'
import store from '@/store'
export default {
  components: {
    MemberSearch
  },
  data() {
    return {
      modalDialog: store.getters.dialog,
      payLoading: false,
      showSm: false,
      cardPayPrice: 0,
      payMoney: '',
      changeMoney: 0.00,
      smCode: '',
      canMod: false,
      orderMessgae: {},
      payTypes: [],
      payTypebs: [],
      mtTgh: '',
      payType: '',
      payTypeb: '',
      changePrice: '',
      cardNum: '',
      showMessage: false,
      cardMessage: {},
      cardPwd: '',
      modPrice: false,
      modPValue: '',
      dialogTableVisible: false,
      remark: '',
      hasLastPrice: false,
      zsmoney: false,
      lastPrice: {},
      authCode: '',
      hyxz: true,
      fyms: '1', // 防疫模式
      type: '',
      code: '',
      integralUse: '0',
      giveMoney: false,
      mealsMemberId: '',
      msCardId: '',
      mealsList: [],
      specialList: [],
      yfdjList: [],
      yfdjId: '',
      showReplacement: false,
      replacement: {},
      tgMemberInfo: {}
    }
  },
  methods: {
    replacementBtn() {
      this.showReplacement = true
      this.tgMemberInfo = {}
    },
    closewReplacement() {
      this.showReplacement = false
    },
    confirmReplacement() {
      this.showReplacement = false
      if (this.tgMemberInfo.id) {
        memberInfo({
          param: {
            id: this.tgMemberInfo.id
          }
        }).then(resb => {
          if (resb.errorCode === '000000') {
            this.replacement = resb.record
            this.yfdjId = ''
            this.getOrderPrice()
          }
        }).catch(err => {
          console.log(err)
        })
        this.tgMemberInfo = {}
      }
    },
    tgMemberSelect(item) {
      const fn = () => {
        this.tgMemberInfo = item
      }
      fn()
    },
    tgMemberClear() {
      this.tgMemberInfo = {}
    },
    smQrbtn() {
      if (this.smCode) {
        this.authCode = this.smCode
        this.showSm = false
      }
    },
    // 订单详情2
    continuePay(id, type, c) {
      this.mtTgh = ''
      this.payMoney = ''
      this.integralUse = '0'
      this.changeMoney = 0.00
      this.cardNum = ''
      this.showMessage = false
      this.cardMessage = {}
      this.cardPwd = ''
      this.modPrice = false
      this.modPValue = ''
      this.remark = ''
      this.authCode = ''
      this.type = type
      this.orderMessgae = {}
      this.lastPrice = {}
      this.hasLastPrice = false
      this.hyxz = true
      this.mealsList = []
      this.yfdjList = []
      this.yfdjId = ''
      this.replacement = {}
      this.tgMemberInfo = {}

      if (type === 'goodsSale') {
        this.code = 'PAY_METHOD_GOODS'
        goodsPayForVenue({
          param: {
            goodsList: id.goodsList,
            memberId: id.memberId,
            remark: id.remark,
            saleType: '0',
            venueId: sessionStorage.getItem('venueId')
          },
          userId: sessionStorage.getItem('userId')
        })
          .then((res) => {
            if (res.errorCode === '000000') {
              this.dialogTableVisible = true
              this.orderMessgae = res.record
              this.remark = res.record.remark || ''
              if (res.record.memberId) {
                memberInfo({
                  param: {
                    id: res.record.memberId
                  }
                }).then(resb => {
                  if (resb.errorCode === '000000') {
                    this.cardNum = resb.record.number
                    this.hyxz = false
                    this.cardMessage = resb.record
                    this.showMessage = true
                    this.$nextTick(() => { this.getDefalutConfig() })
                  }
                }).catch(err => {
                  console.log(err)
                })
              } else {
                this.$nextTick(() => { this.getDefalutConfig() })
              }
            }
          })
      } else if (type === 'assemblyField') {
        this.code = 'PAY_JOINT_SITE'
        this.mealsMemberId = ''
        this.mealsList = []
        this.orderMessgae = id
        if (id.memberId) {
          memberInfo({
            param: {
              id: id.memberId
            }
          }).then(res => {
            if (res.errorCode === '000000') {
              this.cardNum = res.record.number
              this.hyxz = false
              this.cardMessage = res.record
              this.showMessage = true
              this.dialogTableVisible = true
              this.$nextTick(() => { this.getDefalutConfig() })
              console.log('userType', this.orderMessgae)
              console.log('', this.type)
            }
          }).catch(err => {
            console.log(err)
          })
        } else {
          this.dialogTableVisible = true
          this.orderMessgae = id
          this.$nextTick(() => { this.getDefalutConfig() })
        }
      } else if (type === 'specialCardBuy') {
        this.code = 'PAY_METHOD_SPECIAL_CARD'
        this.$emit('studentAddSuccess')
        this.orderMessgae = { ...id, allPrice: id.price }
        this.dialogTableVisible = true
        console.log('id', id)
        if (id.memberId) {
          memberInfo({
            param: {
              id: id.memberId
            }
          }).then(resb => {
            if (resb.errorCode === '000000') {
              this.cardNum = resb.record.number
              this.hyxz = false
              this.cardMessage = resb.record
              this.showMessage = true
              this.$nextTick(() => { this.getDefalutConfig() })
            }
          }).catch(err => {
            console.log(err)
          })
        } else {
          this.$nextTick(() => { this.getDefalutConfig() })
        }
      } else if (type === 'studentAdd') {
        this.code = 'PAY_METHOD_COURSE'
        this.remark = id.mark || ''
        const param = id
        if (id.memberInfo) {
          this.showMessage = true
          this.hyxz = false
          this.cardMessage = id.memberInfo
        }
        param.venueId = sessionStorage.getItem('venueId')
        enrolCoursePc({
          param,
          userId: sessionStorage.getItem('userId')
        })
          .then((res) => {
            if (res.errorCode === '000000') {
              this.dialogTableVisible = true
              this.$emit('studentAddSuccess')
              // this.$emit('studentAddSuccess')
              this.orderMessgae = res.record
              if (id.memberInfo && id.sjFlag === '1') {
                this.getMealsReserveCard()
              }
              this.$nextTick(() => { this.getDefalutConfig() })
            }
          }, () => {
            this.$emit('openSuccess')
          })
      } else if (type === 'studentPay') {
        this.code = 'PAY_METHOD_COURSE'
        courseGoOnPay({
          param: {
            orderId: id.orderId,
            venueId: sessionStorage.getItem('venueId')
          },
          userId: sessionStorage.getItem('userId')
        })
          .then((res) => {
            if (res.errorCode === '000000') {
              this.dialogTableVisible = true
              this.orderMessgae = res.record
              this.remark = res.record.remark || ''
              if (res.record.memberId) {
                memberInfo({
                  param: {
                    id: res.record.memberId
                  }
                }).then(resb => {
                  if (resb.errorCode === '000000') {
                    this.$emit('orderSuccess')
                    this.cardNum = resb.record.number
                    this.hyxz = false
                    this.cardMessage = resb.record
                    if (id.courseType === '4') {
                      this.getMealsReserveCard()
                    }
                    this.showMessage = true
                    this.$nextTick(() => { this.getDefalutConfig() })
                  }
                }).catch(() => {})
              } else {
                this.$nextTick(() => { this.getDefalutConfig() })
              }
            }
          })
      } else if (type === 'goods') {
        this.code = c || 'PAY_METHOD_GOODS'
        goodsOrderContinuePay({
          param: {
            id: id,
            venueId: sessionStorage.getItem('venueId')
          },
          userId: sessionStorage.getItem('userId')
        })
          .then((res) => {
            if (res.errorCode === '000000') {
              this.dialogTableVisible = true
              this.orderMessgae = res.record
              this.remark = res.record.remark || ''
              if (res.record.memberId) {
                memberInfo({
                  param: {
                    id: res.record.memberId
                  }
                }).then(resb => {
                  if (resb.errorCode === '000000') {
                    this.$emit('orderSuccess')
                    this.cardNum = resb.record.number
                    this.hyxz = false
                    this.cardMessage = resb.record
                    this.showMessage = true
                    this.$nextTick(() => { this.getDefalutConfig() })
                  }
                }).catch(() => {})
              } else {
                this.$nextTick(() => { this.getDefalutConfig() })
              }
            }
          })
      } else if (type === 'vipRecharge') {
        this.code = 'PAY_METHOD_RECHARGE'
        if (id.memberId) {
          memberInfo({
            param: {
              id: id.memberId
            }
          }).then(res => {
            if (res.errorCode === '000000') {
              this.dialogTableVisible = true
              this.cardNum = res.record.number
              this.hyxz = false
              this.cardMessage = res.record
              this.showMessage = true
              this.orderMessgae = id
              this.$nextTick(() => { this.getDefalutConfig() })
            }
          }).catch(err => {
            console.log(err)
          })
        }
      } else if (type === 'groupOpen') {
        this.code = 'PAY_METHOD_MEMBER_TEAM'
        this.dialogTableVisible = true
        this.orderMessgae = id
        if (id.memberId) {
          memberInfo({
            param: {
              id: id.memberId
            }
          }).then(res => {
            if (res.errorCode === '000000') {
              this.cardNum = res.record.number
              this.hyxz = false
              this.cardMessage = res.record
              this.showMessage = true
              this.$nextTick(() => { this.getDefalutConfig() })
            }
          }).catch(err => {
            console.log(err)
          })
        } else {
          this.$nextTick(() => { this.getDefalutConfig() })
        }
      } else if (type === 'vipAdd') {
        this.code = 'PAY_METHOD_CARD'
        this.hyxz = false
        this.dialogTableVisible = true
        this.showMessage = true
        this.orderMessgae = {
          ...id,
          orderId: id.id,
          allPrice: id.originalPrice,
          number: c.number
        }
        this.cardMessage = c
        this.cardNum = c.number
        this.$nextTick(() => { this.getDefalutConfig() })
      } else if (type === 'areaSellOrder') {
        this.code = 'PAY_METHOD_SITE'
        this.mealsMemberId = ''
        this.mealsList = []
        if (id.memberId) {
          memberInfo({
            param: {
              id: id.memberId
            }
          }).then(res => {
            if (res.errorCode === '000000') {
              this.cardNum = res.record.number
              this.hyxz = false
              this.cardMessage = res.record
              this.showMessage = true
              this.orderMessgae = id
              this.dialogTableVisible = true
              this.$nextTick(() => { this.getDefalutConfig() })
              if (id.fixedReserve !== '1') {
                this.getMealsReserveCard()
              }
            }
          }).catch(err => {
            console.log(err)
          })
        } else {
          this.dialogTableVisible = true
          this.orderMessgae = id
          this.$nextTick(() => { this.getDefalutConfig() })
        }
      } else if (type === 'comboOrder') {
        this.code = 'PAY_METHOD_MEAL'
        mealPayInfo({
          param: {
            id: id.orderId
          }
        })
          .then((res) => {
            if (res.errorCode === '000000') {
              this.dialogTableVisible = true
              this.orderMessgae = res.record
              this.cardNum = id.memberPhone
              this.remark = res.record.remark || ''
              if (res.record.memberId) {
                memberInfo({
                  param: {
                    id: res.record.memberId
                  }
                }).then(resb => {
                  if (resb.errorCode === '000000') {
                    this.cardNum = resb.record.number
                    this.hyxz = false
                    this.cardMessage = resb.record
                    this.showMessage = true
                    this.$nextTick(() => { this.getDefalutConfig() })
                  }
                }).catch(err => {
                  console.log(err)
                })
              } else if (id.memberPhone) {
                VIPInfo({
                  param: {
                    phoneOrNo: id.memberPhone
                  }
                })
                  .then((res) => {
                    if (res.errorCode === '000000') {
                      this.cardMessage = res.record
                      this.hyxz = false
                      this.showMessage = true
                      this.$nextTick(() => { this.getDefalutConfig() })
                    }
                  })
                  .catch(() => {})
              } else {
                this.$nextTick(() => { this.getDefalutConfig() })
              }
            }
          })
      } else if (type === 'combo') {
        this.code = 'PAY_METHOD_MEAL'
        this.cardNum = id.memberInfo.number
        mealInfo({
          param: {
            mealsList: id.selectedMessage,
            venueId: sessionStorage.getItem('venueId'),
            channelType: '02',
            memberId: id.memberInfo.id,
            remark: id.remark
          },
          userId: sessionStorage.getItem('userId')
        }).then(res => {
          if (res.errorCode === '000000') {
            this.dialogTableVisible = true
            this.orderMessgae = res.record
            this.remark = res.record.remark || ''
            if (res.record.memberId) {
              memberInfo({
                param: {
                  id: res.record.memberId
                }
              }).then(resb => {
                if (resb.errorCode === '000000') {
                  this.cardNum = resb.record.number
                  this.hyxz = false
                  this.cardMessage = resb.record
                  this.showMessage = true
                  this.$nextTick(() => { this.getDefalutConfig() })
                }
              }).catch(err => {
                console.log(err)
              })
            } else {
              this.$nextTick(() => { this.getDefalutConfig() })
            }
          }
        }).catch(err => {
          console.log(err)
        })
      } else if (type === 'ticketOrder') {
        this.code = 'PAY_METHOD_TICKET'
        ticketPayAgain({
          param: {
            id,
            venueId: sessionStorage.getItem('venueId')
          },
          userId: sessionStorage.getItem('userId')
        })
          .then((res) => {
            if (res.errorCode === '000000') {
              this.dialogTableVisible = true
              this.orderMessgae = res.record
              this.remark = res.record.remark || ''
              if (res.record.memberId) {
                memberInfo({
                  param: {
                    id: res.record.memberId
                  }
                }).then(resb => {
                  if (resb.errorCode === '000000') {
                    this.cardNum = resb.record.number
                    this.hyxz = false
                    this.cardMessage = resb.record
                    this.showMessage = true
                    this.$nextTick(() => { this.getDefalutConfig() })
                  }
                }).catch(err => {
                  console.log(err)
                })
              } else {
                this.$nextTick(() => { this.getDefalutConfig() })
              }
            }
          })
      } else if (type === 'financeDefaultSpend') {
        this.code = 'PAY_METHOD_GENERAL'
        this.dialogTableVisible = true
        this.orderMessgae = id
        this.$nextTick(() => { this.getDefalutConfig() })
      } else if (type === 'handlingFees') {
        this.code = 'PAY_METHOD_SERVICE_CHARGE'
        this.dialogTableVisible = true
        this.orderMessgae = id
        this.$nextTick(() => { this.getDefalutConfig() })
      } else if (type === 'ticket') {
        this.code = 'PAY_METHOD_TICKET'
        payInfo({
          param: {
            tickList: id.p,
            venueId: sessionStorage.getItem('venueId'),
            memberId: id.memberId,
            remark: id.remark
          },
          userId: sessionStorage.getItem('userId')
        })
          .then((res) => {
            if (res.errorCode === '000000') {
              this.dialogTableVisible = true
              this.orderMessgae = res.record
              this.remark = res.record.remark || ''
              if (res.record.memberId) {
                memberInfo({
                  param: {
                    id: res.record.memberId
                  }
                }).then(resb => {
                  if (resb.errorCode === '000000') {
                    this.cardNum = resb.record.number
                    this.hyxz = false
                    this.cardMessage = resb.record
                    this.showMessage = true
                    this.$nextTick(() => { this.getDefalutConfig() })
                  }
                }).catch(err => {
                  console.log(err)
                })
              } else {
                this.$nextTick(() => { this.getDefalutConfig() })
              }
            }
          })
      } else if (type === 'defaultReserve') {
        this.code = 'PAY_METHOD_SITE'
        siteOrderInfo({
          param: {
            businessId: id
          },
          userId: sessionStorage.getItem('userId')
        }).then(res => {
          if (res.errorCode === '000000') {
            this.hyxz = false
            this.showMessage = true
            this.orderMessgae = res.record
            this.dialogTableVisible = true
            memberInfo({
              param: {
                id: res.record.memberId
              }
            }).then(resb => {
              if (resb.errorCode === '000000') {
                this.cardNum = resb.record.number
                this.hyxz = false
                this.cardMessage = resb.record
                this.$nextTick(() => { this.getDefalutConfig() })
              }
            }).catch(err => {
              console.log(err)
            })
          }
        }).catch(err => {
          console.log(err)
        })
      } else if (type === 'dinner') {
        this.code = 'PAY_METHOD_DIANCAN'
        goodsPayForVenue({
          param: {
            goodsList: id.goodsList,
            saleType: '1',
            goodsTableId: id.id,
            venueId: sessionStorage.getItem('venueId'),
            memberId: id.memberId || '',
            remark: id.remark || ''
          },
          userId: sessionStorage.getItem('userId')
        })
          .then((res) => {
            if (res.errorCode === '000000') {
              this.dialogTableVisible = true
              this.orderMessgae = res.record
              this.remark = res.record.remark || ''
              if (res.record.memberId) {
                memberInfo({
                  param: {
                    id: res.record.memberId
                  }
                }).then(resb => {
                  if (resb.errorCode === '000000') {
                    this.cardNum = resb.record.number
                    this.hyxz = false
                    this.cardMessage = resb.record
                    this.showMessage = true
                    this.$nextTick(() => { this.getDefalutConfig() })
                  }
                }).catch(err => {
                  console.log(err)
                })
              } else {
                this.$nextTick(() => { this.getDefalutConfig() })
              }
            }
          })
      } else if (type === 'table') {
        this.code = 'PAY_METHOD_DIANCAN'
        goodsPayForVenue({
          param: {
            goodsList: id,
            saleType: '1',
            goodsTableId: c,
            venueId: sessionStorage.getItem('venueId')
          },
          userId: sessionStorage.getItem('userId')
        })
          .then((res) => {
            if (res.errorCode === '000000') {
              this.dialogTableVisible = true
              this.orderMessgae = res.record
              if (res.record.memberId) {
                memberInfo({
                  param: {
                    id: res.record.memberId
                  }
                }).then(resb => {
                  if (resb.errorCode === '000000') {
                    this.cardNum = resb.record.number
                    this.hyxz = false
                    this.cardMessage = resb.record
                    this.showMessage = true
                    this.$nextTick(() => { this.getDefalutConfig() })
                  }
                }).catch(err => {
                  console.log(err)
                })
              } else {
                this.$nextTick(() => { this.getDefalutConfig() })
              }
            }
          })
      } else if (type === 'bracelet') {
        this.code = 'PAY_METHOD_BRACELET'
        this.dialogTableVisible = true
        this.orderMessgae = id
        if (id.memberId) {
          memberInfo({
            param: {
              id: id.memberId
            }
          }).then(res => {
            if (res.errorCode === '000000') {
              this.cardNum = res.record.number
              this.hyxz = false
              this.cardMessage = res.record
              this.showMessage = true
              this.$nextTick(() => { this.getDefalutConfig() })
            }
          }).catch(err => {
            console.log(err)
          })
        } else {
          this.$nextTick(() => { this.getDefalutConfig() })
        }
      } else if (type === 'lease') {
        this.code = 'PAY_METHOD_LEASE'
        equipmentLeaseConfirm({
          param: {
            equipmentConfirmParam: id.selectedMessage,
            venueId: sessionStorage.getItem('venueId'),
            leaseUserType: id.memberInfo.leaseUserType,
            memberId: id.memberInfo.id,
            leaseUserPhone: id.memberInfo.phone,
            leaseUserName: id.memberInfo.nickName || '',
            remark: id.remark
          }
        }).then(res => {
          if (res.errorCode === '000000') {
            this.dialogTableVisible = true
            this.orderMessgae = {
              ...res.record,
              allPrice: res.record.price
            }
            this.remark = id.remark || ''
            if (id.memberInfo.id) {
              memberInfo({
                param: {
                  id: id.memberInfo.id
                }
              }).then(resb => {
                if (resb.errorCode === '000000') {
                  this.cardNum = resb.record.number
                  this.hyxz = false
                  this.cardMessage = resb.record
                  this.showMessage = true
                  this.$nextTick(() => { this.getDefalutConfig() })
                }
              }).catch(err => {
                console.log(err)
              })
            } else {
              this.$nextTick(() => { this.getDefalutConfig() })
            }
          }
        }).catch(err => {
          console.log(err)
        })
      } else if (type === 'leaseList') {
        this.code = 'PAY_METHOD_LEASE'
        equipmentLeaseContinuePay({
          param: {
            id: id.id
          }
        }).then(res => {
          if (res.errorCode === '000000') {
            this.dialogTableVisible = true
            this.orderMessgae = {
              ...res.record,
              allPrice: res.record.price
            }
            this.remark = id.remark || ''
            if (res.record.memberId) {
              memberInfo({
                param: {
                  id: res.record.memberId
                }
              }).then(resb => {
                if (resb.errorCode === '000000') {
                  this.cardNum = resb.record.number
                  this.hyxz = false
                  this.cardMessage = resb.record
                  this.showMessage = true
                  this.$nextTick(() => { this.getDefalutConfig() })
                }
              }).catch(err => {
                console.log(err)
              })
            } else {
              this.$nextTick(() => { this.getDefalutConfig() })
            }
          }
        }).catch(err => {
          console.log(err)
        })
      } else if (type === 'escort') {
        this.code = 'PAY_METHOD_ESCORT'
        escortPayInfo({
          param: {
            orderId: id,
            venueId: sessionStorage.getItem('venueId')
          },
          userId: sessionStorage.getItem('userId')
        })
          .then((res) => {
            if (res.errorCode === '000000') {
              this.dialogTableVisible = true
              const su = res.record
              su.orderId = id
              su.allPrice = su.price
              this.orderMessgae = su
              this.remark = res.record.remark || ''
              if (res.record.memberId) {
                memberInfo({
                  param: {
                    id: res.record.memberId
                  }
                }).then(resb => {
                  if (resb.errorCode === '000000') {
                    this.$emit('orderSuccess')
                    this.cardNum = resb.record.number
                    this.hyxz = false
                    this.cardMessage = resb.record
                    this.showMessage = true
                    this.$nextTick(() => { this.getDefalutConfig() })
                  }
                }).catch(() => {})
              } else {
                this.$nextTick(() => { this.getDefalutConfig() })
              }
            }
          })
      }
    },
    mtZf(code) {
      this.mtTgh = code
    },
    getMealsReserveCard() {
      mealsReserveCard({
        param: {
          memberId: this.orderMessgae.memberId || this.cardMessage.id,
          orderId: this.orderMessgae.orderId
        }
      }).then(res => {
        if (res.errorCode === '000000') {
          this.mealsList = res.record || []
          this.mealsList.forEach(item => {
            if (item.type === '1' || item.type === '4') {
              item.label = item.name + ' 有效期至' + item.validityEndTime
            } else {
              item.label = item.name + ' 剩余：' + item.remainNumCount + '次' + ' 有效期至' + item.validityEndTime
            }
          })
        }
      }).catch(err => {
        console.log(err)
      })
    },
    getSpecialCard() {
      ableOrienteerByOrder({
        param: {
          memberId: this.orderMessgae.memberId || this.cardMessage.id,
          orderId: this.orderMessgae.orderId
        }
      }).then(res => {
        if (res.errorCode === '000000') {
          this.specialList = res.recordList.map(item => {
            item.name = item.name + ' 余额：' + item.amount
            return item
          })
          if (this.specialList.length > 0) {
            this.$set(this, 'msCardId', this.specialList[0].id)
            // this.msCardId = this.specialList[0].id
            this.getOrderPrice()
          }
        }
      }).catch(err => {
        console.log(err)
      })
    },
    payByMoney() {
      if (!this.payMoney) {
        this.changeMoney = 0.00
        return
      }
      if (this.payMoney.length === 1 && [1, 2, 3, 4, 5, 6, 7, 8, 9].indexOf(Number(this.payMoney)) === -1) {
        this.payMoney = ''
        return
      }
      if (this.modPValue) {
        if (parseFloat(this.payMoney) < parseFloat(this.modPValue)) {
          // this.$message.error('实付现金不能小于应付金额')
          this.changeMoney = 0.00
          return
        }
      } else {
        if (parseFloat(this.payMoney) < parseFloat(this.orderMessgae.allPrice)) {
          // this.$message.error('实付现金不能小于应付金额')
          this.changeMoney = 0.00
          return
        }
      }
      this.changeMoney = parseFloat(this.payMoney) - (this.modPrice ? parseFloat(this.modPValue) : parseFloat(this.orderMessgae.allPrice))
    },
    payByMoneyb() {
      if (!this.payMoney) {
        this.changeMoney = 0.00
        return
      }
      if (this.payMoney.length === 1 && [1, 2, 3, 4, 5, 6, 7, 8, 9].indexOf(Number(this.payMoney)) === -1) {
        this.payMoney = ''
        return
      }
      const cardPayPrice = this.cardPayPrice
      let yfMoney = 0
      if (this.modPValue) {
        yfMoney = parseFloat(this.payMoney) - (parseFloat(this.modPValue) - parseFloat(cardPayPrice))
        if (yfMoney <= 0) {
          // this.$message.error('实付现金不能小于应付金额')
          this.changeMoney = 0.00
          return
        }
      } else {
        yfMoney = parseFloat(this.payMoney) - (parseFloat(this.lastPrice.price) - parseFloat(cardPayPrice))
        if (yfMoney <= 0) {
          // this.$message.error('实付现金不能小于应付金额')
          this.changeMoney = 0.00
          return
        }
      }
      this.changeMoney = yfMoney
    },
    searchAction() {
      if (!this.cardNum.length) {
        this.$message.error('请输卡号/手机号')
        return
      }
      VIPInfo({
        param: {
          phoneOrNo: this.cardNum
        }
      })
        .then((res) => {
          if (res.errorCode === '000000') {
            this.cardMessage = res.record
            // this.getMealsReserveCard()
            this.showMessage = true
            this.getOrderPrice()
          }
        })
        .catch(() => {})
    },
    changePayType(item) {
      if (this.payType === item.value) {
        return
      }
      this.integralUse = '0'
      this.payType = item.value
      if (item.value === '13') {
        this.getSpecialCard()
        return
      }
      if (item.value === '04' || item.value === '05' || item.value === '08') {
        this.showSm = true
        this.smCode = ''
        this.$nextTick(() => {
          this.$refs.code.focus()
        })
      }
      this.getOrderPrice()
    },
    changePayTypeb(item) {
      // if (this.payTypeb === item.value) {
      //   return
      // }
      this.integralUse = '0'
      // this.payTypeb = item.value
      if (this.payTypeb === '04' || this.payTypeb === '05' || this.payTypeb === '08') {
        this.showSm = true
        this.smCode = ''
        this.$nextTick(() => {
          this.$refs.code.focus()
        })
      }
    },
    payOrder() {
      // 支付订单
      const param = {}
      param.policyId = this.lastPrice.policy
      param.msCardId = this.msCardId || null

      if (this.remark) {
        param.note = this.remark
      }
      param.change = '0'
      if (this.modPrice) {
        param.change = '1'
        param.changePrice = this.modPValue
        if (!this.modPValue && this.modPValue !== '0' && this.modPValue !== 0) {
          return this.$message.error('请输入消费金额')
        }
        param.integralUse = '0'
      } else {
        param.change = '0'
        param.changePrice = ''
      }
      if (this.payType === '01' || this.payType === '13') {
        param.integralUse = this.integralUse
      } else {
        param.integralUse = '0'
      }
      param.orderId = this.orderMessgae.orderId
      param.payMethod = this.payType
      if (this.payType === '14') {
        param.mixedPay = this.payTypeb
        param.cardPayPrice = (Number(this.cardMessage.remainingMoney) + Number(this.cardMessage.remainingGiveMoney)).toFixed(2)
      }
      param.policyId = this.lastPrice.policyId
      if (this.payType === '13') {
        param.giveMoney = this.giveMoney
      }
      if (this.payType === '01' || this.payType === '14') {
        if (!this.cardMessage.id) {
          this.$message.error('请先搜索会员')
          return
        }
        param.memberId = this.cardMessage.id
        if (this.lastPrice.isRequired === '1') {
          if (!this.cardPwd) {
            this.$message.error('请输入支付密码')
            return
          } else if (this.cardPwd.length !== 6) {
            this.$message.error('请输入6位支付密码')
            return
          }
        }

        param.payPwd = this.cardPwd
        param.giveMoney = this.giveMoney
      }
      if (this.fyms === '0') {
        if (!this.cardMessage.id) {
          this.$message.error('当前防疫模式请先搜索会员')
          return
        }
        param.memberId = this.cardMessage.id
      }
      if (this.payType === '10' || (this.payType === '14' && this.payTypeb === '10')) {
        if (!this.mtTgh) {
          this.$message.error('请输入美团团购号')
          return
        }
        param.couponCode = this.mtTgh
      }
      param.mealsMemberId = this.mealsMemberId
      param.consumeGeneralId = this.yfdjId
      if ((this.payType === '01' || this.payType === '02' || this.payType === '07' || this.payType === '10' || this.payType === '13') || ((this.payTypeb === '01' || this.payTypeb === '02' || this.payTypeb === '07' || this.payTypeb === '10' || this.payTypeb === '13') && this.payType === '14')) {
        this.payLoading = true
        payForOrder({
          param: param
        })
          .then((res) => {
            this.payLoading = false
            if (res.errorCode === '000000') {
              this.$message.success('支付成功')
              this.dialogTableVisible = false
              this.$emit('orderSuccess')
              this.print()
            }
          })
          .catch(() => {
            this.payLoading = false
            // this.$message.error('支付失败，请联系客服')
          })
      } else {
        if (this.lastPrice.allPrice <= 0 || (this.modPrice && this.modPValue.length && this.modPValue <= 0)) {
          this.payLoading = true
          payForOrder({
            param: param
          })
            .then((res) => {
              this.payLoading = false
              if (res.errorCode === '000000') {
                this.dialogTableVisible = false
                this.$emit('orderSuccess')
                this.print()
              }
            })
            .catch(() => {
              this.payLoading = false
            })
        } else {
          if (!this.authCode.length) {
            this.$message.error('请扫描付款码')
            return
          }
          if (this.fyms === '0') {
            if (!this.cardMessage.id) {
              this.$message.error('当前防疫模式请先搜索会员')
              return
            }
          }
          var totalAmount = this.lastPrice.price
          if (this.modPrice) {
            totalAmount = this.modPValue
          }
          var type = this.payType === '04' ? '1' : this.payType === '05' ? '0' : this.payType === '14' ? '4' : '2'
          var status = this.modPrice ? '1' : '0'
          const paramb = {
            policyId: this.lastPrice.policyId,
            memberId: this.cardMessage.id || '',
            type: type,
            status: status,
            authCode: this.authCode,
            outTradeNo: this.orderMessgae.orderId,
            subject: '商品',
            totalAmount: totalAmount
          }
          if (this.payType === '14') {
            paramb.mixedPay = this.payTypeb
            paramb.cardPayPrice = (Number(this.cardMessage.remainingMoney) + Number(this.cardMessage.remainingGiveMoney)).toFixed(2)
          }
          paramb.consumeGeneralId = this.yfdjId
          scanCodePay({
            param: paramb
          })
            .then((res) => {
              if (res.errorCode === '000000') {
                const str = res.record.msg
                if (res.record.code === '0') {
                  this.$message.success(str)
                  this.$emit('orderSuccess')
                  this.dialogTableVisible = false
                  this.print()
                } else if (res.record.code === '2') {
                  this.showLoding(5000, str)
                  setTimeout(() => {
                    orderType({
                      param: {
                        orderId: this.orderMessgae.orderId
                      }
                    })
                      .then((resb) => {
                        const strb = resb.record.msg
                        if (resb.errorCode === '000000') {
                          if (resb.record.code === '0') {
                            this.$message.success(strb)
                            this.$emit('orderSuccess')
                            this.dialogTableVisible = false
                            this.print()
                          } else if (resb.record.code === '2') {
                            this.$message.info(strb)
                          } else {
                            this.$message.error(strb)
                          }
                        }
                      })
                      .catch(() => {})
                  }, 5000)
                } else {
                  this.$message.error(str)
                }
              }
            })
            .catch(() => {
              // this.$message.error('支付失败，请联系客服')
            })
        }
      }
    },
    print() {
      let templateCode = ''
      if (this.type === 'studentAdd' || this.type === 'goodsSale' || this.type === 'dinner' || this.type === 'goods' || this.type === 'table') {
        return false
      }
      switch (this.type) {
        case 'goods':
        case 'specialCardBuy':
          templateCode = 'SPECIAL_CARD_ORDER'
          break
        case 'studentPay':
          templateCode = 'COURSETPML'
          break
        case 'handlingFees':
          templateCode = 'SERVICE_CHARGE_ORDER'
          break
        case 'assemblyField':
          templateCode = 'SITETPML'
          break
        case 'goodsSale':
          templateCode = 'GOODSTPML'
          break
        case 'areaSellOrder':
        case 'defaultReserve':
          templateCode = 'SITETPML'
          break
        case 'comboOrder':
        case 'combo':
          templateCode = 'MEALSTPML'
          break
        case 'ticket':
        case 'ticketOrder':
          templateCode = 'TICKETTPML'
          break
        case 'financeDefaultSpend':
          templateCode = 'CONSUMETPML'
          break
        case 'dinner':
        case 'table':
          templateCode = 'GOODSTPML2'
          break
        case 'vipRecharge':
          templateCode = 'MECHARGETPML'
          break
        case 'vipAdd':
          templateCode = 'MECARDTPML'
          break
        case 'bracelet':
          templateCode = 'BRACELET_TPML'
          break
        case 'groupOpen':
          templateCode = 'MECHARGETPML'
          break
        case 'lease':
        case 'leaseList':
          templateCode = 'LEAST_TMPL'
          break
        case 'escort':
          templateCode = 'ESCORT_ORDER'
          break
        default:
          break
      }
      printOrder({
        param: {
          contentMap: {},
          venueId: sessionStorage.getItem('venueId'),
          workId: this.orderMessgae.orderId,
          templateCode
        }
      })
        .then((res) => {
          console.log(res)
        })
        .catch((err) => {
          console.log(err)
        })
    },
    showLoding(time, title) {
      const loading = this.$loading({
        lock: true,
        text: title,
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.5)'
      })
      setTimeout(() => {
        loading.close()
      }, time)
    },
    cancelOrder() {
      // 取消支付
      this.$emit('cancelOrder')
      this.dialogTableVisible = false
      if (this.type === 'dinner' || this.type === 'ticket') {
        // this.$emit('orderSuccess')
        this.$emit('cancelOrder')
      }
    },
    getDefalutConfig() {
      // configList({ param: { type: '7', code: 'EPIDEMIC_PREVENTION_MODE' }})
      //   .then((res) => {
      //     if (res.errorCode !== '000000') return
      //     const valueList = res.recordList
      //     const obj = valueList.find(item => item.code === 'EPIDEMIC_PREVENTION_MODE')
      //     this.fyms = obj.name
      //   })
      //   .catch((err) => {
      //     console.log(err)
      //   })
      this.$emit('openSuccess')
      configList({ param: { type: '6' }})
        .then((res) => {
          if (res.errorCode !== '000000') return
          const valueListb = res.recordList
          const obj = valueListb.find(item => item.code === 'EDIT_PRICE_CONFIG')
          if (obj && obj.name) {
            this.canMod = true
          }
        })
        .catch((err) => {
          console.log(err)
        })
      configList({ param: { type: '2', code: this.code }})
        .then((res) => {
          if (res.errorCode !== '000000') return
          const arr = res.recordList || []
          const payTypes = []
          const payTypebs = []
          if (res.recordList && res.recordList.length > 0) {
            let payType = res.recordList[0].value
            arr.forEach((e) => {
              if (e.value !== '01' && e.value !== '14' && e.value !== '13') {
                payTypebs.push(e)
              }
              if (e.value === '14') {
                e.show = false
                payTypes.push(e)
              } else {
                e.show = true
                payTypes.push(e)
              }
              if (e.value === '01') {
                if (this.cardMessage.id) {
                  payType = e.value
                } else if (payType === '01') {
                  payType = res.recordList[1].value
                }
              }
            })
            this.payTypes = payTypes
            this.payType = payType
            this.payTypebs = payTypebs
            this.getOrderPrice()
          }
        })
        .catch(() => {})
    },
    getOrderPrice(type) {
      if (this.modPrice) {
        return
      }
      this.lastPrice = {}
      this.hasLastPrice = false
      const param = {}
      param.orderId = this.orderMessgae.orderId
      param.payMethod = this.payType
      param.mealsMemberId = this.mealsMemberId
      param.msCardId = this.msCardId || null
      param.consumeGeneralId = this.yfdjId || null
      if (this.payType === '01') {
        if (this.cardMessage.id) {
          param.memberId = this.cardMessage.id
        } else {
          this.$message.warning('请先搜索会员')
          return
        }
      }
      if (this.cardMessage.id && type !== 1) {
        this.getDjList()
      }
      getPrice(
        {
          param: param
        }
      ).then(res => {
        if (res.errorCode === '000000') {
          this.lastPrice = res.record
          this.hasLastPrice = true
          const payTypes = [...this.payTypes]
          const payTypebs = [...this.payTypebs]
          let yfMoney = 0
          if (this.modPrice) {
            yfMoney = this.modPValue || 0
          } else {
            yfMoney = res.record.price
          }
          yfMoney = Number(yfMoney)
          if (this.cardMessage.id) {
            this.cardPayPrice = (Number(this.cardMessage.remainingMoney) + Number(this.cardMessage.remainingGiveMoney)).toFixed(2)
            const money = Number(this.cardMessage.remainingMoney) + Number(this.cardMessage.remainingGiveMoney)
            if (money > 0 && money < yfMoney) {
              payTypes.forEach((s, i) => {
                if (s.value === '14') {
                  s.show = true
                  if (payTypebs[0] === '14') {
                    this.payTypeb = payTypebs[1].value
                  } else {
                    this.payTypeb = payTypebs[0].value
                  }
                }
              })
            }
          }
          this.payTypes = payTypes
          this.payByMoneyb()
          this.payByMoney()
        }
      }).catch(() => {})
    },
    getDjList() {
      getOneByOrderAndMember(
        {
          param: {
            memberId: this.replacement.id ? this.replacement.id : this.cardMessage.id,
            orderId: this.orderMessgae.orderId
          }
        }
      ).then(res => {
        if (res.errorCode === '000000') {
          this.yfdjList = res.recordList
          // if (res.recordList && res.recordList.length > 0) {
          //  this.yfdjId = res.recordList[0].id
          //  this.getOrderPrice(1)
          // }
        }
      }).catch(() => {})
    },
    gjChange() {
      if (this.cardMessage.id) {
        const payTypes = [...this.payTypes]
        let yfMoney = 0
        if (this.modPrice) {
          yfMoney = this.modPValue || 0
        } else {
          yfMoney = this.lastPrice.price
        }
        this.cardPayPrice = (Number(this.cardMessage.remainingMoney) + Number(this.cardMessage.remainingGiveMoney)).toFixed(2)
        const money = Number(this.cardMessage.remainingMoney) + Number(this.cardMessage.remainingGiveMoney)
        if (money > 0 && money < yfMoney) {
          payTypes.forEach((s, i) => {
            if (s.value === '14') {
              s.show = true
            }
          })
        } else {
          payTypes.forEach((s, i) => {
            if (s.value === '14') {
              s.show = false
            }
            if (this.payType === '14') {
              if (payTypes[0].value === '14') {
                this.payType === payTypes[1].value
              } else {
                this.payType = payTypes[0].value
              }
            }
          })
        }
        this.payTypes = payTypes
      }
    }
  }
}
</script>

<style lang="scss" scoped>
@import '@/styles/variables.scss';

.orderBox {
  min-height: 400px;
  display: flex;

  .orderLeft {
    width: 450px;
    margin-right: 20px;
    margin-bottom: 20px;
    flex: none;

    .orderPriceBt {
      font-size: 16px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #222222;
      line-height: 1;
      margin-bottom: 20px;
    }

    .gjCnt {
      font-size: 14px;
      margin-bottom: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #222222;
      line-height: 14px;

      .el-input {
        width: 100px;
        margin: 0 5px;
      }
    }
  }

  .orderRight {
    flex: 1;

    .pay-style {
      text-align: center;
      height: 36px;
      box-sizing: border-box;
      padding: 0 10px;
      font-size: 14px;
      line-height: 36px;
      vertical-align: middle;
      margin: 0 10px 10px 0;

      &.slelect-pay-style {
        background-color: $primaryColor;
        color: #fff;
      }

      &.normal-pay-style {
        background: #F7F7F7;
        color: #333333;
      }
    }

    .memberDetail {
      flex: 1;
      background: #F4F7FC;
      border-radius: 4px;
      width: 100%;
      padding: 10px 15px;
      display: flex;
      align-items: center;
      margin-bottom: 20px;

      img {
        width: 40px;
        height: 40px;
        border-radius: 20px;
        margin-right: 10px;
      }

      .memberRight {
        flex: 1;
        display: flex;
        flex-wrap: wrap;
        font-size: 13px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #666666;
        line-height: 1.5;

        div {
          width: 50%;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;

          &:first-of-type {
            width: 100%;
            font-size: 14px;
            font-family: PingFangSC-Semibold, PingFang SC;
            font-weight: 600;
            color: #333333;
          }

          span {
            color: #222222;

            &.money {
              color: $SecondColor;
            }
          }
        }
      }
    }

    .zffsBt {
      font-size: 16px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #222222;
      line-height: 16px;
      margin-bottom: 16px;
    }

    .yhzc {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #222222;
      line-height: 1.5;
      margin: 10px 0;

      span {
        color: $primaryColor;
      }
    }

  }
}

.footCnt {
  border-top: 1px solid #DFE2E8;
  width: 1000px;
  margin-left: -30px;
  margin-bottom: -20px;
  box-sizing: border-box;
  padding: 10px 30px;
  line-height: 36px;
  display: flex;
  justify-content: flex-end;
  position: relative;

  .bottom-left {
    position: absolute;
    left: 30px;
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #222222;

    span {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: $SecondColor;

      &.ys {
        font-size: 16px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #222222;
      }

      &.ysje {
        font-size: 16px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        margin-right: 20px;
      }
    }
  }

  .bottom-right {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #222222;

    b {
      color: #333333;
      margin-left: 4px;
    }
  }
}
.smtip {
  font-size: 16px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333333;
line-height: 16px;
margin-top: 30px;
text-align: center;
}
.smImg {
  display: block;
  margin: 20px auto 45px;
  width: 200px;
  height: 200px;
}
.smFoot {
  display: flex;
}
</style>
